<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/include/head.jsp"%>
</head>
<body>
	<div class="easyui-panel" title="查询"style="height: 80px; padding: 5px;" align="center">
		<form id="queryForm">
			<table>
				<tr>
					<td>名称：<input id="name" name="name" class="easyui-textbox"></td>
					<td align="right" style="width: 100px;"><a href="#"	id="searchBtn" class="easyui-linkbutton">查询</a></td>
				</tr>
			</table>
		</form>
	</div>
	<div id="toolbar">
		<a href="javascript:void(0)" class="easyui-linkbutton"  iconcls="icon-add" id="add" plain="true">添加</a>
	</div>
	<table id="dataList" class="easyui-datagrid" >
	</table>
</body>


<script type="text/html" id="operate_template">
			<a href="#"  onclick="view('<!=row.${columnList[0].javaPropertyName}!>')">详情</a>
            <a href="#"  onclick="edit('<!=row.${columnList[0].javaPropertyName}!>')">修改</a> 
			<a href="#"  onclick="del('<!=row.${columnList[0].javaPropertyName}!>')">删除</a> 
</script>
<script type="text/javascript">
	var dialog;
	
	//查询
	function search(){
		$('#dataList').datagrid({
			url:'${ctx}/${simpleBeanName}/ajaxPage.do',
			queryParams:$("#queryForm").serializeJson(),
			toolbar:'#toolbar',
			pagination:true,
			rownumbers:true,
			fitColumns:true,
			singleSelect:true,
			 columns:[[
					<#list columnList as column>
			   		{field:'${column.javaPropertyName}',title:'${column.dbColumnComment}',width:'50'},					
					</#list>								 
			   		{field:'_',title:'操作',align:'center',formatter:function(val,row,index){
			   			return baidu.template("operate_template", {row : row});
			   		}}
			       ]]
		});
	}

	//添加
	$("#add").click(function(){
		dialog = new Dialog({
			Width:600,
			Height:300,
			Title:"添加${config.beanDescription}",
			URL:"${ctx}/${simpleBeanName}/toAdd.do"
		});
		dialog.show();
	});
	
	//修改
	function edit(${beanId}){
		dialog = new Dialog({
			Width:600,
			Height:300,
			Title:"修改${config.beanDescription}",
			URL:"${ctx}/${simpleBeanName}/toEdit.do?${beanId}="+${beanId}
		});
		dialog.show();
	}
	
	//详情
	function view(${beanId}){
		dialog = new Dialog({
			Width:600,
			Height:300,
			Title:"详情${config.beanDescription}",
			URL:"${ctx}/${simpleBeanName}/view.do?${beanId}="+${beanId}
		});
		dialog.show();
	}
	
	//删除
	function del(${beanId}){
		 Dialog.confirm('确定要删除${config.beanDescription}吗？',function(){
			 $.post('${ctx}/${simpleBeanName}/delete.do',{${beanId}:${beanId}},function(result){
        	 	 if(result.success){
        	 		 search();
        	 		 Dialog.alert("操作成功！");
        	 	 }else{
        	 		 Dialog.alert(result.msg);
        	 	 }
         	},'json');
		 });
	}

	
	$(function() {
		search();
		$("#searchBtn").click(function(){
			search();
		});
	});
</script>

</html>